using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace ApiProject.Api.Repository
{

    public interface IRepository<T>
    {


        IQueryable<T> Table { get; }
        
        /// <summary>
        /// 获取实体Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        T GetById(int id);



        /// <summary>
        /// 使用实体对象插入数据
        /// </summary>
        /// <param name="entity">需要插入的对象</param>
        void Insert(T entity);




        /// <summary>
        /// 使用实体对象插入数据(异步)
        /// </summary>
        /// <param name="entity">需要插入的对象</param>
        Task InsertAsync(T entity);




        /// <summary>
        /// 批量插入若干数据
        /// </summary>
        /// <param name="entities">待插入的若干实体数据</param>
        void InsertBulk(IEnumerable<T> entities);
        

        /// <summary>
        /// 批量插入若干数据（异步）
        /// </summary>
        /// <param name="entities">批量插入若干数据</param>
        /// <returns></returns>
        Task InsertBulkAsync(IEnumerable<T> entities);

        

        /// <summary>
        /// 根据对象更新数据
        /// </summary>
        /// <param name="entity">要更新的对象</param>
        void Update(T entity);



        /// <summary>
        /// 根据对象更新数据（批量更新）
        /// </summary>
        /// <param name="id">要更新的对象</param>
        void UpdateBulk(IEnumerable<T> entities);



        /// <summary>
        /// 根据Id删除
        /// </summary>
        /// <param name="id"></param>

        void Delete(int id);
    }


}